dofile (getScriptPath() .. "\\..\\processor\\processor.lua")
dofile (getScriptPath() .. "\\..\\processor\\log.lua")

dofile (getScriptPath() .. "\\..\\lib\\lib.lua")
dofile (getScriptPath() .. "\\..\\lib\\orders.lua")
--dofile (getScriptPath() .. "\\..\\lib\\actions.lua")

script_name = string.gsub(string.gsub(debug.getinfo(1).short_src, "%.[^%.]*$", ""), "^.*[\\/]", "")

data = {
	--delay = 2000,
}

processor:AddInit(function()
	if not lib:isConnected() then return true end
	client_code = lib:GetUser()
	script_id = client_code .. "#" .. script_name
	processor:InitLog(lib.path.log .. script_id .. ".log")
	processor:log("started")
end)

--[[
processor:AddInit(function()
	orders:AddOnLimitStopHandler()
end)
--]]
	
processor:AddTimer(function()
	if not orders:InProcess() then
		local orders_hash = lib:tostring(orders:GetLimits()) .. lib:tostring(orders:GetAllStops())
		
		if orders_hash ~= data.orders_hash then
			data.orders_hash = orders_hash
			
			orders:CleanTakeLimits()
		end
	end
end)

--[[	
processor:AddTimer(function()
	if not orders:InProcess() then
		processor:stop(0)
	end
end)
--]]

